package com.zimmor.rocketmq.consumer;


import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @Author:zimmor
 * @Date: 2021/11/28 11:03
 * @Description 顺序消息消费者，特别设置 consumeMode = ConsumeMode.ORDERLY，其他一样
 * @version: 1.0.0
 */
@Component
@RocketMQMessageListener(topic = "order", consumerGroup = "springboot-mq-consumer-1", messageModel = MessageModel.CLUSTERING, selectorExpression = "tag", consumeMode = ConsumeMode.ORDERLY)
public class OrderConsumer implements RocketMQListener<String> {

    @Override
    public void onMessage(String message) {
//        for (Object o : message) {
//            System.out.println(o);
//        }
//        System.out.println(LocalDateTime.now());
        System.out.println("接收到消息" + message.toString());
//        System.out.println("message = " + message.getContent());
//        System.out.println("code:" + message.getCode());
    }
}
